#include <iostream>
using std::cout;
using std::endl;
/*
17、Create a class that contains a double*. 
The constructor initializes the double* by calling new double 
and assigning a value to the resulting storage from the constructor argument. 

The destructor prints the value that’s pointed to, assigns that value to -1, 
calls delete for the storage, and then sets the pointer to zero. 

Now create a function that takes an object of your class by value, 
and call this function in main(). What happens? Fix the problem by writing a copy-constructor.
*/
class C1{
public:
    double* point;
    
    C1(double d):point(new double(d))
    {
        
    }
    
    C1(const C1 &c1):point(new double(*(c1.point)))
    {
    }
    
    ~C1(){
        cout << "the value is " << *point << endl;
        *point = -1;
        delete point;
        point = NULL;
    }
};

void function(C1 c1)
{
}

int main()
{
    C1 c1(3.14);
    function(c1);
    return 0;
}